package org.poptest.bootstrap;

import org.poptest.annotation.Bootstrap;
import org.poptest.reflect.ReflectionUtils;

/**
 * @author Alan Roche
 *         Date: 03/02/11
 *         Time: 21:19
 */
public final class BootstrapperFactory {
    public static Bootstrapper create(final Class<?> testClass) {
        final Bootstrap bootstrapperAnnotation =
                testClass.getAnnotation(Bootstrap.class);
        final Class<? extends Bootstrapper> bootstrapperClass;
        if (bootstrapperAnnotation != null) {
            bootstrapperClass = bootstrapperAnnotation.value();
        } else {
            bootstrapperClass = DefaultBootstrapper.class;
        }
        return ReflectionUtils.instantiate(bootstrapperClass);
    }
}
